package com.letfox.test.example;

import java.util.Date;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import com.letfox.common.util.UUIDHexGenerator;
import com.letfox.test.util.MyBatisUtil;
import com.letfox.user.dao.UserDao;
import com.letfox.user.enums.UserEnums;
import com.letfox.user.model.UUser;

 
/**
 * 单元测试
 */
public class UserExample {

	/**
	 * 需要单元测试的时候在取消注释
	 */
	private UserDao userDao;
	@Test
	public void addUser(){
		SqlSession session = MyBatisUtil.getSqlSession(true);
		try {
			UUser user = new UUser();
			user.setUserId(UUIDHexGenerator.generator());
			user.setState(UserEnums.UserState.FREEZE.getValue());
			user.setRealName("张三");
			user.setUpdateTime(new Date());
			user.setCreateTime(new Date());
			user.setIdCard("460101XXXXX");
			user.setGender(UserEnums.UserGender.MAN.getValue());
			user.setUserAuthState(UserEnums.UserAuthState.AUTH.getValue());
			userDao = session.getMapper(UserDao.class);
			userDao.insert(user);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
